#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char *ct[4][10]={
      {"","I","II","III","IV","V","VI","VII","VIII","IX"},
      {"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"},
      {"","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"},
      {"","M","MM","MMM"}
    };

char* intToRoman(int num){ 
    int s[4]={ [0 ... 3]=0 };
    char *r=malloc(sizeof(char)*16);
    r[0]='\0';
    int i=0;
    while( num ){
        s[i++]=num%10;
        num/=10;
    }
    for( i-- ; i>=0; i-- )
        strcat(r,ct[i][s[i]]);
    return r;
}

int main(){
    printf("%s\n",intToRoman(333));
    printf("%s\n",intToRoman(3333));
    printf("%s\n",intToRoman(444));
    return 0;
}
